{% extends "mdm/basemdm.html" %}

{% block title %} {{  titulo }} {% endblock %}

{% block contenido %}

<div id="frm" title="{{  titulo }}">
{% if form.is_multipart %}
    <form id="formulario" enctype="multipart/form-data" method="post" action="{{ request.get_full_path }}">
{% else %}
     <form id="formulario" action="{{ request.get_full_path }}" method="post">
{% endif %}
{% csrf_token %}
          {% include "mdm/formsbase.html" %}

</form>
</div>
{% endblock  %}

{% block script %}
     <script>
     $(
          function(){
               // El formulario
               $("#frm").dialog({
                    bgiframe: false,
                    autoOpen: true,
                    width: 600,
                    height: 'auto',
                    position: ['center', 'center'],
                    modal: true,
                    resizable: true,
                    closeOnEscape: false,
                    buttons: {
                         'Aceptar': function() {                             
                              $('#formulario').submit()
                         },
                         'Cancelar': function() {
                              if(confirm('¿Seguro que quieres cancelar?')) {
                                   window.location = '{% url inicio %}'
                              }
                         }
                    },
                    open: function(event, ui) {
                         $(this).css({'max-height': 400, 'overflow-y': 'auto'}); 
                    },
                    close: function(event, ui) { 
                         if(confirm('¿Seguro que quieres cerrar?')) {
                              window.location =  '{% url inicio %}'
                         }
                    }
               })
               
               $('p.error:first').focus()
          }
     )
     </script>
{% endblock %}


